package com.hyh.minio.helper;

import com.hyh.minio.service.FileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * Minio助手
 *
 * @Author: heyuhua
 * @Date: 2021/1/12 10:54
 */
@Component
public class MinioHelper {

    /**
     * 日志
     */
    private static final Logger LOG = LoggerFactory.getLogger(MinioHelper.class);

    /**
     * 文件接口服务
     */
    @Autowired
    private FileService fileService;


    /**
     * 上传
     *
     * @param filename
     */
    public void upload(String filename) {
        Assert.notNull(filename, "filename is null.");
        fileService.upload(filename);
    }

    /**
     * 上传
     *
     * @param filename
     * @param object
     */
    public void upload(String filename, String object) {
        Assert.notNull(filename, "filename is null.");
        Assert.notNull(object, "object is null.");
        fileService.upload(filename, object);
    }

    /**
     * 上传
     *
     * @param filename
     * @param object
     * @param bucket
     */
    public void upload(String filename, String object, String bucket) {
        Assert.notNull(filename, "filename is null.");
        Assert.notNull(object, "object is null.");
        Assert.notNull(bucket, "bucket is null.");
        fileService.upload(filename, object, bucket);
    }


}
